import { createSlice } from '@reduxjs/toolkit';
import { getUser } from "@/api"

import { useDispatch } from 'react-redux';


const initialState = {
    userInfo: {},
    routeData: []
} as any
export const userInfoSlice = createSlice({
    name: 'userInfo',
    initialState,
    reducers: {
        setUserInfo: (state, { payload }) => {
            state.userInfo = payload
        },
        setRoute: async (state, { payload }) => {
            state.routeData = payload
        },
    },

})


export const { setUserInfo, setRoute } = userInfoSlice.actions;
export const state = (state: { userInfo: { userInfo: any; }; }) => state.userInfo.userInfo;
export const permi = (state: { userInfo: { routeData: any; }; }) => state.userInfo?.routeData;
export default userInfoSlice.reducer;

